#include<bits/stdc++.h>
//#define int long long
#define N 100000 + 7
//#define DEBUG

using namespace std;

int t, n, m, l, vx, prx, d[N], v[N], a[N], p[N], ans1, ans2, di, lb, rb;
double vi;

signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifndef DEBUG
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    #endif // DEBUG
    #ifdef DEBUG
    freopen("detect1.in", "r", stdin);
    #endif // DEBUG
    cin >> t;
    for(int ti=0; ti<t; ti++){
        cin >> n >> m >> l >> vx;
        prx = 0, ans1 = 0, ans2 = m - 1;
        for(int i=1; i<=n; i++){
            cin >> d[i] >> v[i] >> a[i];
        }
        for(int i=1; i<=m; i++){
            cin >> p[i];
            prx = max(prx, p[i]);
        }
        sort(p+1, p+m+1);
        for(int i=1; i<=n; i++){
            if(d[i] > prx) continue;
            if(a[i] >= 0){
                if(v[i] > vx){
                    ans1++;
                }else{
                    if(a[i] > 0){
                        vi = sqrt(v[i]*v[i]+2*a[i]*(prx-d[i]));
                        if(vi > vx){
                            ans1++;
                        }
                    }
                }
            }else{
                if(v[i] <= vx) continue;
                di = (vx*vx - v[i]*v[i]) / (a[i]*2);
                lb = lower_bound(p+1, p+m+1, d[i]) - p;
                rb = upper_bound(p+1, p+m+1, di) - 1 - p;
                if(p[rb] == di || p[lb] <= di){
                    ans1++;
                    ans2--;
                }
            }
        }
        if(ans1 == 0){
            ans2 = m;
        }
        cout << ans1 << " " << ans2 << "\n";
    }
    return 0;
}
